<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AddServiceSubNew extends Migrator
{
    public function up() {
        // service_sub 系统表 配置不同业务流程 插入数据
        $table = 'service_sub';
        $list = \think\facade\Db::table($table)->where('serv_type', PRODUCT_AROUND_SHOP_SERV)->findOrEmpty();
        if (empty($list)) {
            $data = [
                'serv_type' => PRODUCT_AROUND_SHOP_SERV,
                'name' => '周边游',
                'type_name' => '周边游',
            ];
            \think\facade\Db::name($table)->insert($data);
        }
        $list = \think\facade\Db::table($table)->where('serv_type', PRODUCT_FOOD_SHOP_SERV)->findOrEmpty();
        if (empty($list)) {
            $data = [
                'serv_type' => PRODUCT_FOOD_SHOP_SERV,
                'name' => '连锁餐饮',
                'type_name' => '连锁餐饮',
            ];
            \think\facade\Db::name($table)->insert($data);
        }

    }

    public function down() {
        \think\facade\Db::table('service_sub')->where('serv_type', 'in',[PRODUCT_AROUND_SHOP_SERV,PRODUCT_FOOD_SHOP_SERV])->delete();
    }
}
